package com.linran.quartz.demo1;

import lombok.extern.slf4j.Slf4j;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.quartz.QuartzJobBean;

/**
 * 原生态的job可以直接实现org.quartz.Job接口
 * spring-context-support可以继承抽象类QuartzJobBean
 */
@Slf4j
@Async
public class ExecutionJob extends QuartzJobBean {

    /**
     * 执行具体任务
     */
    @Override
    public void executeInternal(JobExecutionContext context) throws JobExecutionException {
        //获取之前存入jobDataMap中的Job信息(内部自动实现反序列化)
        QuartzJob quartzJob = (QuartzJob) context.getMergedJobDataMap().get(QuartzJob.JOB_KEY);
        log.info("开始执行:{}",quartzJob.getJobName());
    }
}
